#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
const int maxn = 2e6 + 100;
ll a[maxn], dp[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //算法 O(nlogn）最大计算n=1e7-1e8规模
    ll M;
    cin >> M;
    for (ll i = 1; i <= M; i++)a[i] = i;
    dp[1] = a[1];
    //dp[x]=dp[x-1]+a[x] (x>=2)
    for (ll x = 2; x <= M; x++)dp[x] = dp[x - 1] + a[x];
    for (ll p = 0; p <= M; p++) {
        ll k = dp[p] + M;
        ll q = lower_bound(dp, dp + M + 1, k) - dp;
        if (dp[q] != k || q == p + 1)continue;
        cout << p + 1 << " " << q << endl;
    }
    return 0;
}
